﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Page.Title = "Website đặt tour du lịch";
        Tour Tour = new Tour();
        datalist_noi_bat.DataSource = Tour.getTourByType(Constants.TOUR_NOI_BAT);
        datalist_noi_bat.DataBind();

        datalist_moi_nhat.DataSource = Tour.getTourMoiNhat(Constants.TOP);
        datalist_moi_nhat.DataBind();

        datalist_khuyen_mai.DataSource = Tour.getTourByType(Constants.TOUR_KHUYEN_MAI);
        datalist_khuyen_mai.DataBind();



        //datalist_conten.ItemDataBound += new DataListItemEventHandler(datalist_conten_ItemDataBound);
        //LoaiTour loaiTour = new LoaiTour();
        //datalist_conten.DataSource = loaiTour.getDanhMucTour(Constants.HIEN_DANH_MUC_SAN_PHAM);
        //datalist_conten.DataBind();
    }

    void datalist_conten_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        DataList datalist = (DataList)e.Item.FindControl("datalist_san_pham");

        String loai_tour_id = DataBinder.Eval(e.Item.DataItem, "loai_tour_id").ToString();
        Tour Tour = new Tour();
        List<ObjTour>  lstObjTour = new List<ObjTour>();
        lstObjTour = Tour.getTourByLoaiTourId(loai_tour_id, Constants.TOP);
        if (lstObjTour.Count > 0)
        {
            datalist.DataSource = lstObjTour;
            datalist.DataBind();
        }
        else
        {
            e.Item.FindControl("lb_ten_loai_tour").Visible = false;
            e.Item.FindControl("lb_xem_tat").Visible = false;
        }
    }
}